package com.freesky.web.manager.controller.panel;

import com.freesky.common.dao.entity.HomeNav;
import com.freesky.common.pojo.DataTablesResult;
import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.web.manager.remote.panel.HomeNavigationRemote;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author: 陈玉林
 * @modifiedBy:
 * @date: Create In 16:50 2018/12/12
 * @description: 首页导航
 */
@Controller
@Api(description = "首页导航管理")
public class HomeNavigationController {

    @Autowired
    private HomeNavigationRemote remote;

    @RequiresPermissions("homeNavManage")
    @ApiOperation(value = "进入界面-首页导航列表")
    @GetMapping("/home/nav/page")
    public String page() {
        return "home-navigation/list";
    }

    @ApiOperation(value = "进入界面-首页导航添加")
    @GetMapping(value = "/home/nav/add/page")
    public String addPage() {
        return "home-navigation/add";
    }

    @ApiOperation(value = "进入界面-首页导航编辑")
    @GetMapping(value = "/home/nav/update/page")
    public String updatePage() {
        return "home-navigation/update";
    }

    @ResponseBody
    @ApiOperation(value = "增加首页导航")
    @PostMapping(value = "/home/nav/add")
    public JSONResponse add(@ModelAttribute HomeNav homeNav) {
        return remote.add(homeNav);
    }

    @ResponseBody
    @GetMapping(value = "/home/nav/list")
    @ApiOperation(value = "获取首页导航列表")
    public DataTablesResult list() {
        return remote.list();
    }

    @ResponseBody
    @DeleteMapping(value = "/home/nav/del/{ids}")
    @ApiOperation(value = "删除首页导航")
    public JSONResponse delete(@PathVariable int[] ids) {
        return remote.delete(ids);
    }


    @ResponseBody
    @PostMapping(value = "/home/nav/update")
    @ApiOperation(value = "编辑首页导航")
    public JSONResponse update(@ModelAttribute HomeNav homeNav) {
        return remote.update(homeNav);
    }

}
